/* eslint-disable consistent-return */
/* eslint-disable array-callback-return */

import moment from 'moment';
import { message } from 'antd';
import { routerRedux } from 'dva/router';
import _ from 'lodash';
import {
  getQuoInfo,
  getCostCenter,
  getExecType,
  getInsUnifyFlag,
  getInsAcountList,
  getInsGroupList,
  getSecAccoList,
  getInsIdeList,
  getAccuAcountList,
  getAccuGroupList,
  getSerConfigList,
  getEmpLaborCont,
  isSubmitRepeat,
  submit,
} from '@/services/addemp';
import { matchDict } from '@/utils/utils';

export default {
  state: {
    formRedux: {
      requestAddBaseDto: { formReduxRequestPdInfo: [] },
      requestInsAndAccuDto: {},
      empLaborContDto: {},
    },
    // 上一步骤信息：
    suppId: null,
    contId: null,
    custId: null,
    quoId: null,
    contSerType: 1, // 合同类型
    quoInfo: {}, // 报价单所有信息
    quoPdList: [], // 报价单产品列表

    requestAddBaseDto: {
      idType: '1', // 身份证
      nation: '156', // 中国
      // 收费信息数据
      requestPdInfo: [], // 产品分项设置数据源
    },
    costCenterList: [], // 成本中心列表
    isHasIns: false, // 有无社保
    isHasAccu: false, // 有无公积金
    insUnifyFlag: 1, // 五险合不合一 :1合2不合
    pdSetFlag: '2', // 产品分项设置
    isAssSetFlag: '2', // 社保险种分项设置
    isSupplyRun: false, // 是否由供应商执行
    isInsSupplyRun: false, // 社保是否由供应商执行
    isAccuSupplyRun: false, // 公积金是否由供应商执行

    requestInsAndAccuDto: {
      // 社保公积金信息
    },
    insList: [], // 社保险种
    assSetInsList: [], // 险种分项设置后险种列表
    insKinds: [], // 险种id列表：获取社保账户需要传参
    isSerConfig: false, // 是否使用服务配置
    isInsWageSet: false, // 是否社保工资分项
    isInsIde: false, // 是否有缴费人员类别
    insPayStyleList: [], // 社保缴费方式列表
    insPayStyle: null, // 社保缴费方式
    accuPayStyleList: [], // 公积金缴费方式列表
    accuPayStyle: null, // 公积金缴费方式
    isInsPayStyleSingle: false, // 社保缴费方式是不是单立户
    isAccuPayStyleSingle: false, // 公积金缴费方式是不是单立户
    insAcountList: [], // 社保账户
    insGroupList: [], // 社保组合
    accuAcountList: [], // 公积金账户
    accuGroupList: [], // 公积金组合
    serConfigList: [], // 服务配置列表
    isHasInjury: false, // 有无工伤险
    isSecAccu: false, // 是否维护工伤二级户
    secAccuList: [], // 工伤二级户
    insIdeList: [], // 缴费人员类别列表
    serConfigData: [], // 服务配置数据源

    empLaborContDto: {
      // 合同信息
    },
    laborContDto: {}, // 合同信息
    isDisableCont: false, // 是否可修改信息
    isContEndRequired: false, // 合同结束日期
    isTryDateRequired: true, // 有无试用期
    sendBeginDate: null, // 业务开始年月 获取合同用
    submitData: {}, // 提交时的数据
    isGoBack: false,
    isSocialFlag: false, // 合同显示判断/产品分项显示
  },
  effects: {
    // 获取报价单信息
    *fetchQuoInfo(
      {
        payload: { addEmpSeleInfo, dictCode },
      },
      { call, put, select }
    ) {
      yield put({
        type: 'updateModelData',
        payload: {
          ...addEmpSeleInfo,
        },
      });
      const response = yield call(getQuoInfo, { quoId: addEmpSeleInfo.quoId });
      const costCenterRep = yield call(getCostCenter, { custId: addEmpSeleInfo.custId });
      if (response.success) {
        let quoPdList = [];
        let costCenterList = [];
        const insList = [];
        let insKinds = [];
        const insPayStyleList = [];
        const accuPayStyleList = [];
        let isHasIns = false; // 有无社保
        let isHasAccu = false; // 有无公积金
        let isHasInjury = false; // 有无工伤险
        const sortNumber = (a, b) => a.pdCate - b.pdCate;
        if (response.data.packList.length) {
          response.data.packList.map(pack => {
            if (pack.listQuoPd.length) {
              pack.listQuoPd.map(pd => {
                quoPdList.push(pd);
                if (pd.pdId === 'PDINF_0000000001') {
                  // 社保
                  isHasIns = true;
                  pd.listAttr.forEach(a => {
                    if (a.dictType === 'BIZ_INS_TYPE') {
                      // 缴费险种
                      a.attrValList.forEach(l => {
                        if (l === '5') {
                          isHasInjury = true;
                        }
                        insList.push({
                          // 险种
                          itemCode: l,
                          itemName: matchDict(dictCode.BIZ_INS_TYPE, l),
                        });
                      });
                      insKinds = a.attrValList;
                    }
                    if (a.dictType === 'PAY_FEES_WAY') {
                      // 缴费方式
                      a.attrValList.forEach(l => {
                        insPayStyleList.push({
                          itemCode: l,
                          itemName: matchDict(dictCode.PAY_FEES_WAY, l),
                        });
                      });
                    }
                  });
                }
                if (pd.pdId === 'PDINF_0000000002') {
                  // 公积金
                  isHasAccu = true;
                  pd.listAttr.forEach(a => {
                    if (a.dictType === 'PAY_FEES_WAY') {
                      // 缴费方式
                      a.attrValList.forEach(l => {
                        accuPayStyleList.push({
                          itemCode: l,
                          itemName: matchDict(dictCode.PAY_FEES_WAY, l),
                        });
                      });
                    }
                  });
                }
              });
            }
          });
        }
        if (costCenterRep.success && costCenterRep.data.length) {
          costCenterList = costCenterRep.data;
        }
        const requestAddBaseDto = yield select(state => state.addinfo.requestAddBaseDto);
        quoPdList = quoPdList.sort(sortNumber);
        yield put({
          type: 'updateModelData',
          payload: {
            quoInfo: response.data,
            quoPdList,
            isHasIns,
            isHasAccu,
            costCenterList,
            insList,
            assSetInsList: insList,
            insKinds,
            isHasInjury,
            insPayStyleList,
            accuPayStyleList,
            requestAddBaseDto: { ...requestAddBaseDto, requestPdInfo: quoPdList },
          },
        });
      } else {
        message.warning(response.message || '服务端错误！');
      }
    },
    // 获取执行方
    *fetchExecType({ payload }, { call, put, select }) {
      const response = yield call(getExecType, { areaId: payload.areaId });
      const requestAddBaseDto = yield select(state => state.addinfo.requestAddBaseDto);
      if (response.success) {
        if (payload.index !== undefined) {
          requestAddBaseDto.requestPdInfo[payload.index].execType = `${response.data}`;
          requestAddBaseDto.requestPdInfo[payload.index].isSupplyRun = response.data === 2;
          yield put({
            type: 'updateModelData',
            payload: { requestAddBaseDto },
          });
        } else {
          yield put({
            type: 'updateModelData',
            payload: {
              requestAddBaseDto: { ...requestAddBaseDto, execType: `${response.data}` },
              isSupplyRun: response.data === 2,
            },
          });
        }
        return response.data;
      }
      message.warning(response.message || '获取执行方数据：服务端错误');
    },
    // 获取五险合不合一
    *fetchGetInsUnifyFlag({ payload }, { call, put }) {
      const response = yield call(getInsUnifyFlag, { areaId: payload.areaId });
      if (response.success) {
        if (!payload.record || (payload.record && payload.record.pdId === 'PDINF_0000000001')) {
          yield put({
            type: 'updateModelData',
            payload: {
              insUnifyFlag: response.data.insUnifyFlag || 1,
            },
          });
        }
      } else {
        message.warning(response.message || '获取地方政策五险信息：服务端错误');
      }
      return response;
    },
    // 获取社保账户列表
    *fetchInsAcountList({ payload }, { call, put }) {
      const response = yield call(getInsAcountList, payload);
      if (response.success) {
        if (response.data) {
          yield put({
            type: 'updateModelData',
            payload: {
              insAcountList: response.data,
            },
          });
        } else {
          message.warning('该地区下未维护社保账户');
        }
      } else {
        message.warning(response.message || '获取社保账户列表：服务端错误');
      }
    },
    // 获取社保组合列表
    *fetchInsGroupList({ payload }, { call, put }) {
      const response = yield call(getInsGroupList, payload);
      if (response.success) {
        if (response.data) {
          yield put({
            type: 'updateModelData',
            payload: {
              insGroupList: response.data,
            },
          });
        } else {
          message.warning('该地区下未维护社保组合');
        }
      } else {
        message.warning(response.message || '获取社保组合列表：服务端错误');
      }
    },
    // 获取工伤二级户列表
    *fetchSecAccoList({ payload }, { call, put }) {
      const response = yield call(getSecAccoList, payload);
      if (response.success) {
        if (response.data && response.data.length) {
          response.data.map(item => {
            const temp = item;
            temp.value = item.accoId;
            temp.label = item.accoName;
            temp.isLeaf = (item.injSecAccoDtos && false) || true;
            if (item.injSecAccoDtos) {
              const children = [];
              item.injSecAccoDtos.map(c => {
                children.push({
                  value: c.injSecAccoId,
                  label: c.injSecAccoName,
                  isLeaf: true,
                });
              });
              temp.children = children;
            }
          });
          const secAccuList = response.data;
          let secAccuIntValue;
          if (
            secAccuList.length === 1 &&
            secAccuList[0].injSecAccoDtos &&
            secAccuList[0].injSecAccoDtos.length === 1
          ) {
            secAccuIntValue = [
              secAccuList[0].accoId,
              secAccuList[0].injSecAccoDtos[0].injSecAccoId,
            ];
          }
          yield put({
            type: 'updateModelData',
            payload: {
              secAccuList,
            },
          });
          return secAccuIntValue;
          // eslint-disable-next-line no-else-return
        } else {
          message.warning('该地区下未维护社工伤二级户');
        }
      } else {
        message.warning(response.message || '获取工伤二级户列表：服务端错误');
      }
    },
    // 获取缴费人员列表
    *fetchInsIdeList({ payload }, { call, put }) {
      const response = yield call(getInsIdeList, payload);
      if (response.success) {
        if (response.data) {
          yield put({
            type: 'updateModelData',
            payload: {
              insIdeList: response.data,
              isInsIde: true,
            },
          });
        } else {
          message.warning('该地区下未维护缴费人员');
        }
      } else {
        message.warning(response.message || '获取缴费人员列表：服务端错误');
      }
    },
    // 获取公积金账户列表
    *fetchAccuAcountList({ payload }, { call, put }) {
      const response = yield call(getAccuAcountList, payload);
      if (response.success) {
        if (response.data) {
          yield put({
            type: 'updateModelData',
            payload: {
              accuAcountList: response.data,
            },
          });
        } else {
          message.warning('该地区下未维护公积金账户');
        }
      } else {
        message.warning(response.message || '获取公积金账户列表：服务端错误');
      }
    },
    // 获取公积金组合列表
    *fetchAccuGroupList({ payload }, { call, put }) {
      const response = yield call(getAccuGroupList, payload);
      if (response.success) {
        if (response.data) {
          yield put({
            type: 'updateModelData',
            payload: {
              accuGroupList: response.data,
            },
          });
        } else {
          message.warning('该地区下未维护公积金组合');
        }
      } else {
        message.warning(response.message || '获取公积金组合列表：服务端错误');
      }
    },
    // 获取服务配置列表
    *fetchSerConfigList({ payload }, { call, put }) {
      const response = yield call(getSerConfigList, payload);
      if (response.success) {
        if (response.data && response.data.length) {
          yield put({
            type: 'updateModelData',
            payload: {
              serConfigList: response.data,
            },
          });
        } else {
          yield put({
            type: 'updateModelData',
            payload: {
              serConfigList: [],
            },
          });
          message.warning('该地区下未维护服务配置');
        }
      } else {
        message.warning(response.message || '获取服务配置列表：服务端错误');
      }
    },
    // 获取劳动合同信息
    *fetchEmpLaborCont({ payload }, { call, put }) {
      const response = yield call(getEmpLaborCont, payload);
      if (response.success) {
        if (response.data) {
          yield put({
            type: 'getContInfo',
            payload: response.data,
          });
        }
      } else {
        message.warning(response.message || '获取劳动合同信息：服务端错误');
      }
    },
    // 提交判重
    *submitRepeat({ payload }, { call, put, select }) {
      yield put({
        type: 'getSubmitData',
        payload,
      });
      const custId = yield select(state => state.addinfo.custId);
      const { pdSetFlag, isAssSetFlag, requestInsInfo, requestPdInfo } = yield select(
        state => state.addinfo.submitData
      );
      if (pdSetFlag === '1') {
        const { cityId, execType } = payload.requestAddBaseDto;
        const isIncludeArea = requestPdInfo.some(
          item => item.cityId === cityId && item.execType === execType
        );
        if (!isIncludeArea) {
          message.warning(
            '派出信息中填写的执行地和执行方在产品分项设置中不存在，如果设置产品分项，请确保产品分项中包含派出信息中的执行地和执行方。'
          );
          return { warningCode: 1 };
        }
      }
      if (isAssSetFlag === '1' && !requestInsInfo.length) {
        message.warning('产品分项设置时请至少选择一个险种！');
        return { warningCode: 1 };
      }
      const isRepeatData = {
        custId,
        idType: payload.requestAddBaseDto.idType,
        idCode: payload.requestAddBaseDto.idCode,
        beginDate: payload.requestAddBaseDto.sendBeginDate,
      };
      const response = yield call(isSubmitRepeat, isRepeatData);
      return response;
    },
    // 提交数据
    // eslint-disable-next-line no-shadow
    submit:[
      function* (_, { call, put, select }) {
        const submitData = yield select(state => state.addinfo.submitData);
        const response = yield call(submit, submitData);
        if (response.success) {
          const state = {
            formRedux: {
              requestAddBaseDto: { formReduxRequestPdInfo: [] },
              requestInsAndAccuDto: {},
              empLaborContDto: {},
            },
            quoInfo: {}, // 报价单所有信息
            quoPdList: [], // 报价单产品列表

            requestAddBaseDto: {
              idType: '1', // 身份证
              nation: '156', // 中国
              // 收费信息数据
              requestPdInfo: [], // 产品分项设置数据源
            },
            costCenterList: [], // 成本中心列表
            isHasIns: false, // 有无社保
            isHasAccu: false, // 有无公积金
            insUnifyFlag: 1, // 五险合不合一 :1合2不合
            pdSetFlag: '2', // 产品分项设置
            isAssSetFlag: '2', // 社保险种分项设置
            isSupplyRun: false, // 是否由供应商执行

            requestInsAndAccuDto: {
              // 社保公积金信息
            },
            insList: [], // 社保险种
            insKinds: [], // 险种id列表：获取社保账户需要传参
            isSerConfig: false, // 是否使用服务配置
            isInsWageSet: false, // 是否社保工资分项
            isInsIde: false, // 是否有缴费人员类别
            insPayStyleList: [], // 社保缴费方式列表
            insPayStyle: null, // 社保缴费方式
            accuPayStyleList: [], // 公积金缴费方式列表
            accuPayStyle: null, // 公积金缴费方式
            isInsPayStyleSingle: false, // 社保缴费方式是不是单立户
            isAccuPayStyleSingle: false, // 公积金缴费方式是不是单立户
            insAcountList: [], // 社保账户
            insGroupList: [], // 社保组合
            accuAcountList: [], // 公积金账户
            accuGroupList: [], // 公积金组合
            serConfigList: [], // 服务配置列表
            isHasInjury: false, // 有无工伤险
            isSecAccu: false, // 是否维护工伤二级户
            secAccuList: [], // 工伤二级户
            insIdeList: [], // 缴费人员类别列表
            serConfigData: [], // 服务配置数据源

            empLaborContDto: {
              // 合同信息
            },
            isDisableCont: false, // 是否可修改信息
            isContEndRequired: false, // 合同结束日期
            isTryDateRequired: true, // 有无试用期
            sendBeginDate: null, // 业务开始年月 获取合同用
            submitData: {}, // 提交时的数据
          };
          yield put({
            type: 'updateModelData',
            payload: { ...state },
          });
          if (response.message) {
            message.warning(response.message);
          }
          yield put(
            routerRedux.push({
              pathname: '/customservicemanage/addemployee/addemployfinish',
            })
          );
        } else {
          message.warning(`${response.message || '增员失败！'}`);
        }
      },
      { type:'throttle',ms:10000 }
    ]
  },

  reducers: {
    // 设置修改当前state数据
    updateModelData(state, { payload }) {
      return {
        ...state,
        ...payload,
      };
    },

    // 设置收费信息数据
    updateChargeData(state, { payload }) {
      let { requestAddBaseDto, formRedux } = state;
      const others = {};
      Object.entries(payload).forEach(([key, value]) => {
        if (key !== 'requestPdInfo') {
          others[key] = value;
        }
      });
      if (payload && payload.requestPdInfo) {
        const { requestPdInfo } = requestAddBaseDto;
        const { formReduxRequestPdInfo } = formRedux.requestAddBaseDto;
        payload.requestPdInfo.forEach((item, index) => {
          let obj = {};
          Object.entries(item).forEach(([key, value]) => {
            obj[key] = value.value;
          });
          obj = { ...requestPdInfo[index], ...obj };
          requestPdInfo[index] = obj;
          formReduxRequestPdInfo[index] = item;
        });
        requestAddBaseDto = { ...requestAddBaseDto, requestPdInfo };
        formRedux = {
          ...formRedux,
          requestAddBaseDto: { ...formRedux.requestAddBaseDto, formReduxRequestPdInfo },
        };
      }
      if (others) {
        const obj = {};
        const formObj = {};
        Object.entries(others).forEach(([key, value]) => {
          obj[key] = value.value;
          formObj[key] = value;
        });
        requestAddBaseDto = { ...requestAddBaseDto, ...obj };
        formRedux = {
          ...formRedux,
          requestAddBaseDto: { ...formRedux.requestAddBaseDto, ...formObj },
        };
      }

      return {
        ...state,
        requestAddBaseDto,
        formRedux,
      };
    },
    // 设置险种分项数据
    updateIndSetData(state, { payload }) {
      const { requestAddBaseDto } = state;
      const temp = payload;
      temp.isAssSetFlag = payload.isAssSetFlag === '1' ? '2' : '1';
      const newArr= _.cloneDeep(requestAddBaseDto);
      if (payload.isAssSetFlag === '1') {
        // 打开险种分项设置
        const obj = {};
        let insIndex = 0;
        newArr.requestPdInfo.forEach((item, index) => {
          if (item.pdId === 'PDINF_0000000001') {
            obj.cityId = item.cityId;
            obj.execType = item.execType;
            obj.startDate = item.startDate;
            obj.isSupplyRun = item.isSupplyRun;
            insIndex = index + 1;
            payload.insList.map(ins => {
              const obj1 = ins;
              obj1.pdName = ins.itemName;
              obj1.ass = ins.itemCode;
              obj1.isSelected = true;
              Object.assign(ins, obj);
            });
          }
        });
        newArr.requestPdInfo.splice(insIndex, 0, ...payload.insList);
      } else {
        newArr.requestPdInfo.splice(1, payload.insList.length);
      }
      return {
        ...state,
        isAssSetFlag: payload.isAssSetFlag,
        requestAddBaseDto: newArr,
      };
    },
    // 设置社保公积金信息数据
    updateInsAccuData(state, { payload }) {
      let { requestInsAndAccuDto, formRedux } = state;
      const obj = {};
      const formObj = {};
      Object.entries(payload).forEach(([key, value]) => {
        obj[key] = value.value;
        formObj[key] = value;
      });
      requestInsAndAccuDto = { ...requestInsAndAccuDto, ...obj };
      formRedux = {
        ...formRedux,
        requestInsAndAccuDto: { ...formRedux.requestInsAndAccuDto, ...formObj },
      };
      return {
        ...state,
        requestInsAndAccuDto,
        formRedux,
      };
    },
    // 设置合同信息数据
    updateContData(state, { payload }) {
      let { empLaborContDto, formRedux } = state;
      const obj = {};
      const formObj = {};
      Object.entries(payload).forEach(([key, value]) => {
        obj[key] = value.value;
        formObj[key] = value;
      });
      empLaborContDto = { ...empLaborContDto, ...obj };
      formRedux = {
        ...formRedux,
        empLaborContDto: { ...formRedux.empLaborContDto, ...formObj },
      };
      return {
        ...state,
        empLaborContDto,
        formRedux,
      };
    },
    // 获取劳动合同信息
    getContInfo(state, { payload }) {
      const contInfo = payload[0];
      Object.entries(contInfo).forEach(([key, value]) => {
        if (!value) {
          delete contInfo[key];
        }
        if (
          key === 'contSignWay' ||
          key === 'contType' ||
          key === 'fixedDeadlnFlag' ||
          key === 'probtnFlag' ||
          key === 'laborHour' ||
          key === 'entryMedExamFlag' ||
          key === 'signFlag'
        ) {
          contInfo[key] = `${value}`;
        }
        if (
          key === 'contBeginDate' ||
          key === 'contEndDate' ||
          key === 'probtnBeginDate' ||
          key === 'probtnEndDate' || 
          key === 'signDate'
        ) {
          contInfo[key] = contInfo[key] && moment(parseInt(contInfo[key], 10));
        }
      });
      let { empLaborContDto } = state;
      empLaborContDto = { ...empLaborContDto, ...contInfo };
      return {
        ...state,
        empLaborContDto,
      };
    },
    // 获取提交数据
    getSubmitData(state, { payload }) {
      const {
        contId,
        custId,
        quoId,
        suppId,
        contSerType,
        insUnifyFlag,
        isAssSetFlag,
        isInsWageSet,
        isSerConfig,
        pdSetFlag,
        assSetInsList,
        requestAddBaseDto: { requestPdInfo },
      } = state;
      let submitData = {};
      const { requestAddBaseDto, requestInsAndAccuDto, empLaborContDto } = payload;
      // 基本信息 ：requestAddBaseDto
      const newRequestPdInfo = [];
      const requestInsInfo = [];
      if (requestAddBaseDto) {
        Object.entries(requestAddBaseDto).forEach(([key, value]) => {
          if (!value && value !== 0) {
            // 不存在
            requestAddBaseDto[key] = '';
          }
          switch (key) {
            case 'cityId':
              requestAddBaseDto[key] = value.key;
              break;
            case 'entryDate': // 日期
              requestAddBaseDto[key] = value && value.format('YYYY-MM-DD');
              break;
            case 'birthDate': // 日期
              requestAddBaseDto[key] = value && value.format('YYYY-MM-DD');
              break;
            case 'chrgBeginDate': // 年月
              requestAddBaseDto[key] = value && value.format('YYYY-MM');
              break;
            case 'sendBeginDate': // 年月
              requestAddBaseDto[key] = value && value.format('YYYY-MM-01');
              break;
            case 'requestPdInfo': // 年月
              if (pdSetFlag === '1') {
                requestPdInfo.forEach(item => {
                  if (item.pdId) {
                    newRequestPdInfo.push({
                      cityId: item.cityId.key,
                      execType: item.execType,
                      pdId: item.pdId,
                      startDate: item.startDate && item.startDate.format('YYYY-MM-01'),
                    });
                  } else if (item.isSelected) {
                    requestInsInfo.push({
                      ass: item.ass,
                      beginDate: item.startDate && item.startDate.format('YYYY-MM-01'),
                    });
                  }
                });
              }
              break;
            default:
              break;
          }
        });
        delete requestAddBaseDto.requestPdInfo;
        requestAddBaseDto.custContId = contId;
        requestAddBaseDto.custId = custId;
        requestAddBaseDto.quoId = quoId;
        requestAddBaseDto.sendCorp = suppId;
        requestAddBaseDto.sendType = contSerType;
      }

      const insWageList = [];
      if (requestInsAndAccuDto) {
        // 社保公积金信息 requestInsAndAccuDto
        Object.entries(requestInsAndAccuDto).forEach(([key, value]) => {
          if (!value && value !== 0) {
            // 不存在
            requestInsAndAccuDto[key] = '';
          }
          if (key === 'injSecAccoId') {
            const arr1 = value[0];
            const arr2 = value[1];
            requestInsAndAccuDto.insAccoId = arr1;
            requestInsAndAccuDto[key] = arr2;
          }
        });
        // 社保工资分项打开
        if (isInsWageSet) {
          assSetInsList.forEach(item => {
            insWageList.push({
              ass: item.itemCode,
              wage: requestInsAndAccuDto[`wage_${item.itemCode}`],
            });
            delete requestInsAndAccuDto[`wage_${item.itemCode}`];
          });
        }
      }
      if (empLaborContDto) {
        // 合同信息 empLaborContDto
        Object.entries(empLaborContDto).forEach(([key, value]) => {
          if (!value && value !== 0) {
            // 不存在
            empLaborContDto[key] = '';
          }
          switch (key) {
            case 'cityId':
              empLaborContDto[key] = value.key;
              break;
            case 'contBeginDate': // 日期
              empLaborContDto[key] = value && value.format('YYYY-MM-DD');
              break;
            case 'contEndDate': // 日期
              empLaborContDto[key] = value && value.format('YYYY-MM-DD');
              break;
            case 'probtnBeginDate': // 日期
              empLaborContDto[key] = value && value.format('YYYY-MM-DD');
              break;
            case 'probtnEndDate': // 日期
              empLaborContDto[key] = value && value.format('YYYY-MM-DD');
              break;
              case 'signDate': // 日期
              empLaborContDto[key] = value && value.format('YYYY-MM-DD');
              break;
            case 'requestPdInfo': // 年月
              if (pdSetFlag === '1') {
                value.forEach(item => {
                  requestPdInfo.push({
                    cityId: item.cityId.key,
                    execType: item.execType,
                    pdId: item.pdId,
                    startDate: item.startDate && item.startDate.format('YYYY-MM'),
                  });
                });
              }
              break;
            default:
              break;
          }
        });
      }

      submitData = {
        requestAddBaseDto,
        requestInsAndAccuDto: { ...requestInsAndAccuDto, insWageList },
        requestPdInfo: newRequestPdInfo, // 产品分项
        requestInsInfo, // 产品分项下的险种
        empLaborContDto: empLaborContDto || {},
        insSetFlag: insUnifyFlag,
        isAssSetFlag,
        isInsWageFlag: isInsWageSet ? '1' : '2',
        isSerSetFlag: isSerConfig ? '1' : '2',
        pdSetFlag,
      };
      return {
        ...state,
        submitData,
      };
    },
  },
};
